package com.ray.monitor.model.po;

import com.ray.monitor.util.SizeUtils;

/**
 * 进程监控信息对象
 *
 * @author LiaoYuXing-Ray
 * @version 1.0
 * @createDate 2024/5/23 9:35
 **/
public class ProcessMonitor {
    /**
     * 进程名
     */
    private String processName;
    /**
     * 进程ID
     */
    private Integer pid;
    /**
     * 父进程ID
     */
    private Integer PPid;
    /**
     * 进程CPU占用百分比
     */
    private Double cpu;
    /**
     * 进程的占用内存 RSS（Resident Set Size）以字节为单位
     */
    private Long rss;
    /**
     * 进程占用总内存的百分比
     */
    private Double memory;
    /**
     * 进程的线程数
     */
    private Integer threadCount;

    public String getProcessName() {
        return processName;
    }

    public void setProcessName(String processName) {
        this.processName = processName;
    }

    public Integer getPid() {
        return pid;
    }

    public void setPid(Integer pid) {
        this.pid = pid;
    }

    public Integer getPPid() {
        return PPid;
    }

    public void setPPid(Integer PPid) {
        this.PPid = PPid;
    }

    public Double getCpu() {
        return cpu;
    }

    public void setCpu(Double cpu) {
        this.cpu = cpu;
    }

    public Long getRss() {
        return rss;
    }

    public void setRss(Long rss) {
        this.rss = rss;
    }

    public Double getMemory() {
        return memory;
    }

    public void setMemory(Double memory) {
        this.memory = memory;
    }

    public Integer getThreadCount() {
        return threadCount;
    }

    public void setThreadCount(Integer threadCount) {
        this.threadCount = threadCount;
    }

    @Override
    public String toString() {
        return "ProcessMonitor{" +
                "processName='" + processName + '\'' +
                ", pid=" + pid +
                ", PPid=" + PPid +
                ", cpu=" + String.format("%.4f", cpu) + "%" +
                ", rss=" + SizeUtils.formatBytes(rss) +
                ", memory=" + String.format("%.4f", memory) + "%" +
                ", threadCount=" + threadCount +
                '}';
    }
}
